import logging
from src.common.mem_data import MemData

LOG = logging.getLogger()


class OpenPage():
    def __init__(self):
        self.browser = MemData.browser
        self.page = None
        self.url = MemData.config['url']['taobao_pc_login']
        self.js1 = '''() =>{Object.defineProperties(navigator,{webdriver:{get: () => false}})}'''

    async def open_page(self):
        self.page = await self.browser.newPage()
        MemData.page=self.page
        await self.page.goto(self.url)
        await self.page.evaluate(self.js1)
        LOG.info('open {}'.find(self.url))

    async def run(self):
        await self.open_page()
